package com.fireline.beauty.cashier;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;

import com.zgw.fireline.base.frame.IFunction;
import com.zgw.fireline.base.dataset.Dataset;
import com.zgw.fireline.base.IDataBaseProvide;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.Label;
import com.zgw.fireline.base.controls.DataTable;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.ToolItem;
import com.fireline.beauty.jdbc.SqliteJdbcImpl;
import com.zgw.fireline.base.controls.DataTableColumn;

/**
 * 佘额变动
 * */
public class YebdView implements IFunction {

	private Shell shell;
	private String hybh;
	/**
	 * @wbp.nonvisual location=57,532
	 */
	private final Dataset yebdSet = new Dataset(
			"select * from yebd where hybh=?", SqliteJdbcImpl.INSTANCE);

	/**
	 * @wbp.parser.entryPoint
	 */
	@Override
	public Control createControl(Composite parent) {
		this.shell = parent.getShell();
		yebdSet.setKeyColumns(new String[] {});
		Composite content = new Composite(parent, SWT.NONE);
		content.setLayout(new GridLayout(1, false));

		ToolBar toolBar = new ToolBar(content, SWT.FLAT | SWT.RIGHT);
		toolBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
				1, 1));

		ToolItem tltmNewItem = new ToolItem(toolBar, SWT.NONE);
		tltmNewItem.setText("打印");

		ToolItem tltmNewItem_1 = new ToolItem(toolBar, SWT.NONE);
		tltmNewItem_1.setText("导出");

		DataTable dataTable = new DataTable(content, SWT.BORDER
				| SWT.FULL_SELECTION, yebdSet);
		dataTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1,
				1));
		dataTable.setHeaderVisible(true);
		dataTable.setLinesVisible(true);

		DataTableColumn dataTableColumn = new DataTableColumn(dataTable,
				SWT.NONE, "rq");
		dataTableColumn.setText("变动日期");
		dataTableColumn.setWidth(80);

		DataTableColumn dataTableColumn_1 = new DataTableColumn(dataTable,
				SWT.NONE, "lx");
		dataTableColumn_1.setText("变动类型");
		dataTableColumn_1.setWidth(80);
		
		DataTableColumn dataTableColumn_9 = new DataTableColumn(dataTable, SWT.NONE,"xmbh");
		dataTableColumn_9.setText("项目名称");
		dataTableColumn_9.setWidth(80);

		DataTableColumn dataTableColumn_2 = new DataTableColumn(dataTable,
				SWT.RIGHT, "je_inc");
		dataTableColumn_2.setText("佘额增加");
		dataTableColumn_2.setWidth(80);

		DataTableColumn dataTableColumn_3 = new DataTableColumn(dataTable,
				SWT.RIGHT, "je_dec");
		dataTableColumn_3.setText("佘额减少");
		dataTableColumn_3.setWidth(80);

		DataTableColumn dataTableColumn_4 = new DataTableColumn(dataTable,
				SWT.RIGHT, "cs_inc");
		dataTableColumn_4.setText("次数增加");
		dataTableColumn_4.setWidth(80);

		DataTableColumn dataTableColumn_5 = new DataTableColumn(dataTable,
				SWT.RIGHT, "cs_dec");
		dataTableColumn_5.setText("次数减少");
		dataTableColumn_5.setWidth(80);

		DataTableColumn dataTableColumn_6 = new DataTableColumn(dataTable,
				SWT.RIGHT, "syje");
		dataTableColumn_6.setToolTipText("当时卡内剩余金额");
		dataTableColumn_6.setText("剩余金额");
		dataTableColumn_6.setWidth(80);

		DataTableColumn dataTableColumn_7 = new DataTableColumn(dataTable,
				SWT.RIGHT, "sycs");
		dataTableColumn_7.setToolTipText("当时卡内剩余次数");
		dataTableColumn_7.setText("剩余次数");
		dataTableColumn_7.setWidth(80);

		DataTableColumn dataTableColumn_8 = new DataTableColumn(dataTable,
				SWT.NONE, "czy");
		dataTableColumn_8.setText("操作人");
		dataTableColumn_8.setWidth(80);

		DataTableColumn dtblclmnBz = new DataTableColumn(dataTable, SWT.NONE,
				"bz");
		dtblclmnBz.setText("备注");
		dtblclmnBz.setWidth(80);
		setParams();
		return content;
	}

	public void refresh(String hybh) {
		this.hybh = hybh;
		setParams();
		yebdSet.update();
	}

	protected void setParams() {
		yebdSet.setParam(0, hybh);
	}
}
